package com.lwj.liwanjia.view.activity.work.shang_jia.spfabu;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.bm.library.PhotoView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.base.BaseFragment;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/1/14.
 */

public class PhotoViewFragment extends BaseFragment {
    public static Fragment getInstance(String imageUrl) {
        PhotoViewFragment fragment = new PhotoViewFragment();
        Bundle bundle = new Bundle();
        bundle.putString("imageUrl", imageUrl);
        fragment.setArguments(bundle);
        return fragment;
    }

    @BindView(R.id.photo_view)
    PhotoView photoView;

    private String imageUrl;

    @Override
    protected void initView(View view) {
        Bundle bundle = getArguments();
        if (bundle != null) {
            imageUrl = bundle.getString("imageUrl");
        }

        //启动图片缩放
        photoView.enable();
        Glide.with(getActivity()).load(imageUrl).thumbnail(0.1f).diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(photoView);
        photoView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                getActivity().finish();
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_photo_view;
    }
}
